package com.tudouji.project.customer.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tudouji.framework.aspectj.lang.annotation.Log;
import com.tudouji.framework.aspectj.lang.enums.BusinessType;
import com.tudouji.project.customer.domain.Custbaseinfo;
import com.tudouji.project.customer.service.ICustbaseinfoService;
import com.tudouji.framework.web.controller.BaseController;
import com.tudouji.framework.web.domain.AjaxResult;
import com.tudouji.common.utils.poi.ExcelUtil;
import com.tudouji.framework.web.page.TableDataInfo;

/**
 * 客户经营情况Controller
 * 
 * @author tudouji
 * @date 2022-05-18
 */
@RestController
@RequestMapping("/customer/custbaseinfo")
public class CustbaseinfoController extends BaseController
{
    @Autowired
    private ICustbaseinfoService custbaseinfoService;

    /**
     * 查询客户经营情况列表
     */
    @PreAuthorize("@ss.hasPermi('customer:custbaseinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(Custbaseinfo custbaseinfo)
    {
        startPage();
        List<Custbaseinfo> list = custbaseinfoService.selectCustbaseinfoList(custbaseinfo);
        return getDataTable(list);
    }

    /**
     * 导出客户经营情况列表
     */
    @PreAuthorize("@ss.hasPermi('customer:custbaseinfo:export')")
    @Log(title = "客户经营情况", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Custbaseinfo custbaseinfo)
    {
        List<Custbaseinfo> list = custbaseinfoService.selectCustbaseinfoList(custbaseinfo);
        ExcelUtil<Custbaseinfo> util = new ExcelUtil<Custbaseinfo>(Custbaseinfo.class);
        return util.exportExcel(list, "custbaseinfo");
    }

    /**
     * 获取客户经营情况详细信息
     */
    @PreAuthorize("@ss.hasPermi('customer:custbaseinfo:query')")
    @GetMapping(value = "/{guid}")
    public AjaxResult getInfo(@PathVariable("guid") String guid)
    {
        return AjaxResult.success(custbaseinfoService.selectCustbaseinfoById(guid));
    }

    /**
     * 新增客户经营情况
     */
    @PreAuthorize("@ss.hasPermi('customer:custbaseinfo:add')")
    @Log(title = "客户经营情况", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Custbaseinfo custbaseinfo)
    {
        return toAjax(custbaseinfoService.insertCustbaseinfo(custbaseinfo));
    }

    /**
     * 修改客户经营情况
     */
    @PreAuthorize("@ss.hasPermi('customer:custbaseinfo:edit')")
    @Log(title = "客户经营情况", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Custbaseinfo custbaseinfo)
    {
        return toAjax(custbaseinfoService.updateCustbaseinfo(custbaseinfo));
    }

    /**
     * 删除客户经营情况
     */
    @PreAuthorize("@ss.hasPermi('customer:custbaseinfo:remove')")
    @Log(title = "客户经营情况", businessType = BusinessType.DELETE)
	@DeleteMapping("/{guids}")
    public AjaxResult remove(@PathVariable String[] guids)
    {
        return toAjax(custbaseinfoService.deleteCustbaseinfoByIds(guids));
    }
}
